<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'资源添加', styles:'bootstrap,font-awesome,animate,style,dtvalidate,layer,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
    </style>
    <%}%>
</head>
<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-offset-1 col-sm-10" style="margin-left: -10px;width: 100%;">
                <button type="button" class="return-btn btn btn-w-m btn-primary">返回</button>
                <div style="border-color: #e7eaec;border-image: none;border-style: solid solid none;border-width: 4px 0px;padding-bottom: 15px;margin-top: 10px;" ></div>
            </div>
        </div>
    </div>
</div>
<!-- START 内容部分 -->
<div class="container" >
    <form class="form-horizontal" id="info-form" method="post" autocomplete="off" style="margin: auto">
        <input type="hidden" name="id" value="${createPlan.id}">
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">柜号</label>
            <div class="col-sm-6">
                <input type="text" id="createPlanNo" readonly disabled name="createPlanNo"  class="form-control" value="${createPlan.createPlanNo}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">柜型</label>
            <div class="col-sm-6">
                <select id="createPlanCabinetName" name="createPlanCabinetName"  class="form-control">
                    <option value="">请选择</option>
                    <%for(var dict in cabinet){%>
                    <option value="${dict.cabinetName}" <%if(createPlan.createPlanCabinetName == dict.cabinetName){print("selected");}%>  >${dict.cabinetName}</option>
                    <%}%>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">运输方式</label>
            <div class="col-sm-6">
                <select id="createPlanTransport" name="createPlanTransport"  class="form-control">
                    <option value="">请选择</option>
                    <%for(var dict in transport){%>
                    <option value="${dict.transportName}" <%if(createPlan.createPlanTransport == dict.transportName){print("selected");}%> >${dict.transportName}</option>
                    <%}%>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">国家</label>
            <div class="col-sm-6">
                <select id="createPlanCountry" name="createPlanCountry"  class="form-control">
                    <option value="">请选择</option>
                    <%for(var dict in country){%>
                    <option value="${dict.detailName}" <%if(createPlan.createPlanCountry == dict.detailName){print("selected");}%>>${dict.detailName}</option>
                    <%}%>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">装柜地点</label>
            <div class="col-sm-6">
                <select id="createPlanPlaceName"   class="form-control" xm-select="createPlanPlaceName" xm-select-search>
                    <option value="">请选择</option>
                    <%for(var dict in supplier){%>
                    <option value="${dict.supplierName}">${dict.supplierName}</option>
                    <%}%>
                </select>
                <input type="hidden" id="createPlanPlace"value="${createPlan.createPlanPlace}" name="createPlanPlace">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label text-right">预计装柜时间</label>
            <div class="col-sm-6">
                <input type="text" id="createPlanPlaceDate" name="createPlanPlaceDate" placeholder="请选择开始时间" class="form-control" value="${createPlan.createPlanPlaceDate}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">船期</label>
            <div class="col-sm-6">
                <input type="text" id="createPlanBoatDate" name="createPlanBoatDate" placeholder="请选择开始时间" class="form-control" value="${createPlan.createPlanBoatDate}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">订舱费用</label>
            <div class="col-sm-6">
                <input type="text" id="createPlanPrice" name="createPlanPrice" class="form-control" value="${createPlan.createPlanPrice}">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">ReferenceId</label>
            <div class="col-sm-6">
                <input type="text" id="createPlanReferenceId" name="createPlanReferenceId" value="${createPlan.createPlanReferenceId}" placeholder="请输入ReferenceId" class="form-control">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- END 内容部分 -->

<!-- START 公共脚本 -->
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn,laydate,layer,chosen,chosen-demo'}){}%>
<!-- END 公共脚本 -->
<script>
    laydate.render({
        elem: '#createPlanPlaceDate',
        type: 'date',
        format: 'yyyy-MM-dd'
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#createPlanBoatDate',
        type: 'date',
        format: 'yyyy-MM-dd'
        ,trigger: 'click'
    });
    formSelects.render('createPlanPlaceName');
    var names=$("#createPlanPlace").val();
    if(names.length>0) {
        var list = names.split(",");
        var ids = [];
        for (var i = 0; i < list.length; i++) {
            ids.push(list[i]);
        }
        formSelects.value('createPlanPlaceName', ids);
    }

    var cvalidator;
    $(function(){

        //初始化验证器
        cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
        //提交表单
        $('.save-btn').on('click',function(){
            var createPlanNo=$("#createPlanNo").val();
            if(createPlanNo==''){
                parent.layer.msg('请填写柜号！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }
            var createPlanCabinetName=$("#createPlanCabinetName").val();
            if(createPlanCabinetName==''){
                parent.layer.msg('请选择柜型！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }
            var createPlanCountry=$("#createPlanCountry").val();
            if(createPlanCountry==''){
                parent.layer.msg('请选择国家！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }
            var createPlanPlaceName=formSelects.value('createPlanPlaceName', 'nameStr');
            if(createPlanPlaceName==''){
                parent.layer.msg('请选择装柜地点！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }else{
                $("#createPlanPlace").val(formSelects.value('createPlanPlaceName', 'nameStr'));

            }
            //活动结束时间
            var createPlanPlaceDate=$("#createPlanPlaceDate").val();
            if(createPlanPlaceDate=='') {
                parent.layer.msg('请选择装柜时间！', {icon: 0, time: 1500, shade: [0.8, '#393D49']});
                return;
            }

            //数据提交
            $.post('/sea/physical/createPlan/usave.do',$('#info-form').serialize(),function(data){
                if( data.ok ){
                    parent.layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']}, function(){
                        parent.$planTable.bootstrapTable('refresh');
                        parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
                    });
                }else{
                    parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                }
            });
        });

        //返回
        $('.return-btn').on('click',function(){
            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
        });
    });
</script>
</body>
</html>